package cn.xfdzx.android.apps.shop.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import cn.xfdzx.android.apps.shop.R;
import cn.xfdzx.android.apps.shop.bean.ShopOrderListBeen;
import cn.xfdzx.android.apps.shop.contract.ItemClickListener;
import cn.xfdzx.android.apps.shop.presenter.ShopInGoodListPresenter;
import cn.xfdzx.android.apps.shop.util.Utils;

/**
 * @author gzk
 * @date 2020/5/18 0018
 * 商家入驻  订单管理的列表中的商品
 * description：
 */
public class ShopInOrderGoodListAdapter extends RecyclerView.Adapter {


    private List<ShopOrderListBeen.DataBean.CartInfoBean> mList;
    private ItemClickListener itemClickListener;


    private Context mContext;
    private final LayoutInflater mLayoutInflater;


    public ShopInOrderGoodListAdapter(Context mContext, List<ShopOrderListBeen.DataBean.CartInfoBean> list ) {
        this.mContext = mContext;
        this.mList = list;


        //以后用它来初始化布局
        mLayoutInflater = LayoutInflater.from(mContext);
    }

    @NonNull
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {

        return new ShopInOrderGoodListAdapter.OrderViewHolder0(mContext, mLayoutInflater.inflate(R.layout.item_shop_in_order_good_list, null));


    }

    @Override
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {

        ShopInOrderGoodListAdapter.OrderViewHolder0 orderViewHolder0 = (ShopInOrderGoodListAdapter.OrderViewHolder0) holder;
        orderViewHolder0.setData(position);


    }


    @Override
    public int getItemCount() {
        return mList.size();
    }


    public class OrderViewHolder0 extends RecyclerView.ViewHolder {

        @BindView(R.id.tv_good_name)
        TextView tvGoodName;
        @BindView(R.id.tv_good_num)
        TextView tvGoodNum;


        private Context mContext;

        public OrderViewHolder0(Context mContext, View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
            this.mContext = mContext;

        }

        public void setData(int position) {


            tvGoodName.setText(mList.get(position).getProductInfo().getStore_name());
            tvGoodNum.setText("x "+mList.get(position).getCart_num());


//            tvGoodOldPrice.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);


        }
    }

    public void setItemClickListener(ItemClickListener itemClickListener) {
        this.itemClickListener = itemClickListener;
    }
}
